package com.jswlw.controller.admin.biz;

import com.github.pagehelper.Page;
import com.jswlw.common.BaseException;
import com.jswlw.common.ResponseStatus;
import com.jswlw.controller.BaseController;
import com.jswlw.entity.biz.DistributorAmountConsume;
import com.jswlw.service.biz.DistributorAmountConsumeService;
import com.jswlw.service.biz.DistributorService;
import com.jswlw.web.manager.SessionAdminManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.Date;
import java.util.Objects;

@Controller
@RequestMapping("/admin/biz/distributionAmountConsume")
public class AdminDistributionAmountConsumeController extends BaseController {

    @Autowired
    DistributorAmountConsumeService service;
    @Autowired
    DistributorService distributorService;

    @RequestMapping("/index")
    public String index(Model model) {
        return "biz/distributionAmountConsume/index";
    }

    /**
     * 广告列表
     *
     * @param
     * @return
     */
    @RequestMapping("/list")
    @ResponseBody
    public Object list(@RequestBody DistributorAmountConsume amountConsume) {
        if (Objects.nonNull(SessionAdminManager.getCurrentUser().getDistributor())) {
            amountConsume.setDistributorIds(SessionAdminManager.getCurrentUser().getDistributor().getChildrenIds());
        }
        Page<DistributorAmountConsume> page = service.queryPage(amountConsume);
        return pageResult(page.getResult(), page.getTotal());
    }
}
